package net.ncraft.mc.ezframework.core.handler.configuration;

import net.ncraft.mc.ezframework.core.SpigotEzFrameworkCore;
import org.bukkit.configuration.file.FileConfiguration;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

public class ConfigurationCenter {
    private static final Map<String, FileConfiguration> CONFIGURATIONS = new HashMap<>();

    public static void addConfiguration(String name, FileConfiguration config) {
        CONFIGURATIONS.put(name, config);
    }

    public static FileConfiguration getConfiguration(String name) {
        return CONFIGURATIONS.get(name);
    }

    public static void saveConfiguration(FileConfiguration config,String name) {
        try {
            config.save(new File(SpigotEzFrameworkCore.getPlugin().getDataFolder(), name));
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
